<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Thêm sản phẩm</title>
        <style>
            .login{
                padding-left: 20px;
                width:920px;
                margin-bottom: 10px;
                overflow: hidden;
            }
            .left{
                width:300px;
                float: left;
            }
            .right{
                margin-left: 455px;
            }
            input#txt{
                height: 30px;
                width:410px;
            }
            form input[name='Add']{
                width:120px;
                background:#3883cc;
                color:white;
                font-weight: bold;
                cursor:pointer;
                height:30px;
                margin-left: 300px;
                margin-bottom: 30px;
            }
            form input[name='Edit']{
                width:120px;
                background:#3883cc;
                color:white;
                font-weight: bold;
                cursor:pointer;
                height:30px;
            }
            form input[name='Delete']{
                width:120px;
                background:#3883cc;
                color:white;
                font-weight: bold;
                cursor:pointer;
                height:30px;
            }
        </style>
        <script>
            $(document).ready(function() {
                $("#promotion").change(function(){
                    alert('Ban doi thanhc cong');
                });
            });
        </script>
    </head>
    <body>
        <h2 style="font-family:arial;font-size: 16px; margin:10px 0px 10px 10px; color: #EE314F;">THÔNG TIN SẢN PHẨM</h2>
        <form action="SaveAdd" method="POST" name="product" enctype="multipart/form-data">
            <div class="login">
                <div class="left">
                    <?php
                    if (isset($_GET['pro_id'])) {
                        $product = new Admin_Model_Product();
                        $pro = $product->getProductById($_GET['pro_id']);
                        ?>
                        <input type="hidden" name="txtProID" value="<?php echo $_GET['pro_id'] ?>"/>
                        <?php
                    }
                    ?>
                    <label><strong>Tên sản phẩm:</strong></label>
                    <input type="text" name="txtNameProduct" id="txt" class="required" value="<?php if (isset($_GET['pro_id'])) echo $pro['pro_name'] ?>"/>
                    <label><strong>Khuyến mại</strong></label>
                    <select name="promotion" style="margin-top:10px; margin-bottom: 10px;">
                        <option value="0">Chọn chương trình khuyến mại</option>
                        <?php
                        $promotion = new Admin_Model_Promotion();
                        $promo_rows = $promotion->getPromotion();
                        foreach ($promo_rows as $promo) {
                            ?>
                            <option value="<?php echo $promo['id'] ?>"><?php echo $promo['name_promo'] ?></option>
                            <?php
                        }
                        ?>
                    </select>
                    <label><strong>Giảm giá</strong></label>        
                    <input type="text" name="txtGiamgia" id ="txtGiamgia" class="required" value="<?php echo $number['promo_number'] ?>"/>
                    <label><strong>Giá cũ:</strong></label>
                    <input type="text" name="txtPriceOld" id="txt" class="required" value="<?php if (isset($_GET['pro_id'])) echo $pro['pro_price_old'] ?>"/>
                    <label><strong>Giá mới</strong></label>        
                    <input type="text" name="txtPriceNew" id ="txt" class="required" value="<?php if (isset($_GET['pro_id'])) echo $pro['pro_price'] ?>"/>
                </div>
                <div class="right">
                    <label><strong>Số lượng:</strong></label>
                    <input type="text" name="txtNumber" id="txt" class="required" value="<?php if (isset($_GET['pro_id'])) echo $pro['pro_number'] ?>"/>
                    <label><strong>Nhóm sản phẩm:</strong></label>
                    <select name="group" style="margin-top:10px; margin-bottom: 10px;">
                        <option value="0">Chọn nhóm sản phẩm</option>
                        <?php
                        $categories = new Admin_Model_Categories();
                        $cate_rows = $categories->getCate();
                        if (isset($_GET['pro_id'])) {
                            $pro_cate = $product->getCate($_GET['pro_id']);
                        }
                        foreach ($cate_rows as $value) {
                            ?>
                            <option value="<?php echo $value['cate_id'] ?>" <?php
                        if (isset($_GET['pro_id'])) {
                            if ($pro_cate['cate_id'] == $value['cate_id']) {
                                echo 'selected';
                            }
                        }
                            ?>><?php echo $value['cate_name'] ?></option>
                                    <?php
                                }
                                ?>
                    </select>
                    <?php
                    if (isset($_GET['pro_id'])) {
                        $pro_cates = $product->getCateS($_GET['pro_id']);
                    }
                    ?>
                    <label><strong>Nhóm nhỏ:</strong></label>
                    <select name="groupSmall" style="margin-top:10px; margin-bottom: 10px;">
                        <option value="0">Chọn nhóm nhỏ</option>
                        <?php
                        $cate_small = $categories->getCateSmall();
                        foreach ($cate_small as $v) {
                            ?>
                            <option value="<?php echo $v['cates_id'] ?>" <?php if (isset($_GET['pro_id'])) if ($pro_cates['cates_id'] == $v['cates_id']) echo 'selected';  ?>><?php echo $v['cates_name'] ?></option>
                            <?php
                        }
                        ?>
                    </select>
                    <label><strong>Ảnh sản phẩm:</strong></label>
                    <?php
                    if (isset($_GET['pro_id'])) {
                        ?>
                        <img src="<?php echo URL_BASE . '/templates/admin/' . $pro['pro_img'] ?>" width="100" height="100" alt="No Image"/>
                    <?php } ?>
                    <input type="file" name="image"/>
                </div>
            </div>
            <div class="login" >
                <div class="left">
                    <label><strong>Chi tiết sản phẩm 1:</strong></label>
                    <input type="text" name="txtdetail1" id="txt" class="required" value="<?php if (isset($_GET['pro_id'])) echo $pro['pro_name'] ?>"/>
                    <label><strong>Chi tiết sản phẩm 2:</strong></label>
                    <input type="text" name="txtdetail2" id ="txtGiamgia" class="required" value="<?php echo $number['promo_number'] ?>"/>
                    <label><strong>Chi tiết sản phẩm 3:</strong></label>        
                    <input type="text" name="txtdetail3" id ="txtGiamgia" class="required" value="<?php echo $number['promo_number'] ?>"/>
                     <label><strong>Chất liệu:</strong></label>
                    <input type="text" name="txtSub" id="txt" class="required" value="<?php if (isset($_GET['pro_id'])) echo $pro['pro_price_old'] ?>"/>
                    <label><strong>Cân nặng:</strong></label>
                    <input type="text" name="txtW" id="txt" class="required" value="<?php if (isset($_GET['pro_id'])) echo $pro['pro_price_old'] ?>"/>

                </div>
                <div class="right">
                    <label><strong>Màu:</strong></label>
                    <input type="text" name="txtColor" id="txt" class="required" value="<?php if (isset($_GET['pro_id'])) echo $pro['pro_price_old'] ?>"/>
                    <label><strong>Chi tiết màu</strong></label>        
                    <input type="text" name="txtColorDetail" id ="txt" class="required" value="<?php if (isset($_GET['pro_id'])) echo $pro['pro_price'] ?>"/>
                    <label><strong>Size:</strong></label>
                    <input type="text" name="txtSize" id="txt" class="required" value="<?php if (isset($_GET['pro_id'])) echo $pro['pro_name'] ?>"/>
                    <label><strong>Chi tiết size:</strong></label>
                    <input type="text" name="txtSizeDetail" id ="txtGiamgia" class="required" value="<?php echo $number['promo_number'] ?>"/>
                    <label><strong>Chi tiết kiểu dáng:</strong></label>        
                    <input type="text" name="txtStyleDetail" id ="txtGiamgia" class="required" value="<?php echo $number['promo_number'] ?>"/>

                </div>

                <?php
                if (isset($_GET['pro_id'])) {
                    ?>
                    <input type="submit" value="Sửa" name="Edit"/>
                    <?php
                } else {
                    ?>
                    <input type="submit" value="Thêm" name="Add"/>
                    <?php
                }
                ?>
            </div>
        </form>
    </body>
</html>
